# GDIR define
GDIR=../../..



# params
CC=gcc
CXX=g++
EXTRADEFS=-DLINUX_OS
MACIPATH=$(GDIR)/MaCI
UTILSPATH=$(GDIR)/utils
BUSPATH=$(MACIPATH)/bus
DRIVERPATH=$(MACIPATH)/drivers
MACIINTERFACEPATH=$(MACIPATH)/interfaces
# External includes
include $(GDIR)/GIMI/Makefile.gimi
include $(MACIPATH)/interfaces/MaCI-interfaces.Makefile
INCLUDES=-I$(UTILSPATH) -I$(MACIPATH) $(INCGIMI) -I$(MACIPATH)/interfaces -I$(MACIPATH)/interfaces/common -I$(MACIPATH)/interfaces/MaCICtrl
CFLAGS=-O0 -g3 -Wall $(INCLUDES) $(CE) $(EXTRADEFS)
CPPFLAGS=-O0 -g3 -Wall $(INCLUDES) -Weffc++ $(EXTRADEFS)
LD=g++
LDFLAGS=
LIBS=-lrt -lpthread $(LIBSGIMI) -lcurses


# Sources 'base' (required external links)
SRCSC=$(CGIMI) 
SRCSCPP=$(CPPGIMI) 
VPATH=

# Construct final lists of CPP and C objects
OBJSC=$(SRCSC:.c=.o)
OBJSCPP=$(SRCSCPP:.cpp=.opp)

# Define COMPILE and LINK commands
COMPILEC=$(CC) $(CFLAGS) -c
COMPILECPP=$(CXX) $(CPPFLAGS) -c
LINK=$(LD) $(LDFLAGS) $(LIBS)

.PHONY: all clean real-clean

all:	JointGroupCtrlData_standalone 

# Rules
JointGroupCtrlData_standalone: $(OBJSC) \
		$(UTILSPATH)/binbag.opp JointGroupCtrlData.cpp
	@$(COMPILECPP) -D COMPILE_JOINTGROUPCTRLDATA_STANDALONE_MAIN JointGroupCtrlData.cpp -o JointGroupCtrlData.opp
	@echo "      [CC-STANDALONE] JointGroupCtrlData.cpp"
	@$(LINK) -o $@ $(OBJSC) \
		      JointGroupCtrlData.opp $(UTILSPATH)/binbag.opp
	@echo "      [LD] $@"


clean:
	@rm -f *.o *.opp JointGroupCtrlData_standalone 
	@echo "      [CLEAN]"

real-clean realclean: clean 
	@rm -f $(OBJSC) $(OBJSCPP) *~
	@echo "      [REAL-CLEAN]"


# Compile rule for all .o (.c) file
%.o:	%.c
	@$(COMPILEC) -o $@ $<
	@echo "      [CC] $<"

# Compile rule for all .opp (.cpp) files
%.opp:	%.cpp
	@$(COMPILECPP) -o $@ $<
	@echo "      [CXX] $<"

